<script type="text/javascript" src="options/options.js"></script>

<script type="text/javascript">

	chrome.extension.onRequest.addListener(
		function(request, sender, sendResponse) {
			var options = new GestureOptions();
			options.LoadSettings();
			
			var userGestures = options.UserGestures;			
			if (userGestures[request.gestures] != null) {
				switch(userGestures[request.gestures]) {
					case options.ActionTypes["NewTab"]:
						chrome.tabs.create({url:"chrome://newtab/"}); 
						break;
					case options.ActionTypes["CloseTab"]:
						chrome.tabs.remove(sender.tab.id);
						break;
					case options.ActionTypes["HistoryBack"]:
						chrome.tabs.sendRequest(sender.tab.id, {action: "goBack"});
						break;
					case options.ActionTypes["HistoryForward"]:
						chrome.tabs.sendRequest(sender.tab.id, {action: "goForward"});
						break;
				}
			}
			
			sendResponse({});
	});
</script>